#ifndef LOGINDB_H
#define LOGINDB_H

#include <QObject>
#include <QStringList>
#include <QSqlDatabase>
#include <QSqlRecord>
#include <QSqlQuery>
#include <QSqlTableModel>
#include <QSqlQueryModel>
#include "loginUser.h"

class LoginDB : public QObject
{
    Q_OBJECT
public:
    explicit LoginDB(QObject *parent = nullptr);

    bool createLoginDB(const QString dbPath = QString("UserData.db"));

    bool updateUserInfo(const QString &name, const QString &passwd);

    void initModel();

    void refreshModel();

    void deleteUser(const int row);

    void addUser(LoginUser *user);

    void updateUser(LoginUser *user, int row);

    QStringList getUsersList();

    QSqlQueryModel *getModel() const;

    void getUserById(LoginUser *user, int row);


signals:

public slots:

private:
    QString dbName;
    QSqlDatabase db;
    QStringList usersList;

    QSqlQueryModel *model;
};

#endif // LOGINDB_H
